package kinectData.models;

import java.util.Date;
import java.util.StringTokenizer;

import javax.vecmath.Point3d;

/**
 * Represents Kinect and Device acceleration data.
 * 
 * @author Markus
 */
public class AccelerometerData {
	
	private String deviceId;
	private long trackingTime = 0;
	private Point3d dataPoint;
	
	public AccelerometerData(Point3d data) {
		this.deviceId = "skeleton";
		this.dataPoint = data;
		this.trackingTime = new Date().getTime();
	}

	public AccelerometerData(String data) {
		StringTokenizer st = new StringTokenizer(data, "#");
		this.deviceId = st.nextToken();
		st.nextToken(); // Ignore ACC label
		double x = Double.parseDouble(st.nextToken());
		double y = Double.parseDouble(st.nextToken());
		double z = Double.parseDouble(st.nextToken());
		this.dataPoint = new Point3d(x, y, z);
		this.trackingTime = new Date().getTime();
	}
	
	public String getId() {
		return deviceId;
	}
	
	public long getTrackingTime() {
		return trackingTime;
	}

	public Point3d getDataPoint() {
		return dataPoint;
	}

	public void setTrackingTime(long trackingTime) {
		this.trackingTime = trackingTime;
	}
	
	public String toString(){
		return String.format("%s,%f,%f,%f", deviceId, dataPoint.x, dataPoint.y, dataPoint.z);
	}
}
